package com.kma.summer2012.client.view.mainPage;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import com.kma.summer2012.client.presenters.mainPage.MainPagePresenter;
import com.kma.summer2012.client.presenters.mainPage.widgets.DownBarPresenter;
import com.kma.summer2012.client.presenters.mainPage.widgets.MainTablePresenter;
import com.kma.summer2012.client.presenters.mainPage.widgets.RightSideBarPresenter;
import com.kma.summer2012.client.styles.style2.Recources;
import com.kma.summer2012.client.view.mainPage.widgets.DownBar;
import com.kma.summer2012.client.view.mainPage.widgets.MainTable;
import com.kma.summer2012.client.view.mainPage.widgets.RightSideBar;

/**
 * Created with IntelliJ IDEA.
 * User: EUGENE
 * Date: 2/10/13
 * Time: 6:22 PM
 * To change this template use File | Settings | File Templates.
 */
public class MainPage extends Composite implements MainPagePresenter.Display {

    @UiField
    protected RightSideBar rightSideBar;
    @UiField
    protected MainTable mainTable;

    private Integer tableID;

    interface MainPageUiBinder extends UiBinder<HTMLPanel, MainPage> {
    }

    private static MainPageUiBinder ourUiBinder = GWT.create(MainPageUiBinder.class);

    public MainPage() {
        HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);
        this.initWidget(rootElement);
        mainTable.addStyleName(Recources.INSTANCE.styles().tableShadow());
        MainTablePresenter mpp = new MainTablePresenter(this.mainTable);
        this.tableID = this.mainTable.getTableID();
        RightSideBarPresenter rsbp = new RightSideBarPresenter(this.rightSideBar);
        rsbp.setTableID(this.tableID);

        DownBar downBar = new DownBar();
        DownBarPresenter dbp = new DownBarPresenter(downBar);
        this.mainTable.setAdditionalControls(downBar);
        dbp.setTableID(this.tableID);
    }

    public Widget asWidget() {
        return this;
    }

    @Override
    public Integer getTableID() {
        return this.tableID;
    }


}